/**
 * 
 */
package com.module.osr.ui.stormbringer.charcreator.widgets;

import com.ahq.main.H1HighlightBorder;
import com.dalonedrau.jogl.engine.Action;
import com.dalonedrau.jogl.engine.GameApplet;
import com.dalonedrau.jogl.engine.InputEvent;
import com.dalonedrau.jogl.engine.Interactive;
import com.dalonedrau.jogl.opengl.ui.Button;
import com.dalonedrau.jogl.opengl.ui.GuiComponent;
import com.dalonedrau.jogl.opengl.ui.UIFactory;
import com.dalonedrau.jogl.opengl.ui.panel.LandscapePagePanel;
import com.dalonedrau.jogl.opengl.ui.panel.Panel;
import com.dalonedrau.jogl.opengl.ui.panel.PortraitPagePanel;
import com.module.osr.engine.OSRController;
import com.module.osr.stormbringer.bus.SBCharacter;
import com.module.osr.stormbringer.bus.SBPlayer;
import com.module.stormbringer.globals.Globals;
import com.rpg.base.RPGConsts;

/**
 * @author Donald
 */
public final class AttributesOptions extends LandscapePagePanel {
	/** the "Re-Roll" button. */
	private Button	btnRoll;
	/** Creates a new instance of {@link AttributesOptions}. */
	public AttributesOptions() {
		super(Panel.LANDSCAPE_CENTER);
		//super.setHorizontalAlignment(GuiComponent.TEXT_JUSTIFY);
		btnRoll = UIFactory.getInstance().getStandardButton("Re-Roll");
		btnRoll.setHighlightable(true);
		btnRoll.setActive(true);
		btnRoll.setHighlightBorder(new H1HighlightBorder());
		btnRoll.addAction(new Action() {
			/**
			 * {@inheritDoc}
			 */
			@Override
			public void performAction() {
				try {
					SBCharacter pc = 
						(SBCharacter) Interactive.getInstance().getIO(0);
					// roll attributes
					InputEvent.getInstance().addAction(
							SBPlayer.getInstance(), // object
							SBPlayer.class.getMethod(
									"rollFreshHero", 
									new Class[] { SBCharacter.class }), 
							new Object[] { pc }
							);
					//SBPlayer.getInstance().rollFreshHero(pc);
				} catch (Exception ex) {
					JOGLErrorHandler.getInstance().fatalError(ex);
				}
			}
		});
		super.addChild(btnRoll);
	}
}
